package 初始线程;
//线程的状态
public class Demo_10 {
    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(()->{
            while(!Thread.currentThread().isInterrupted()){
                System.out.println("111");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    break;
                }
            }
        });

//        运行前
        System.out.println(thread.getState());

        thread.start();
//        运行后
        System.out.println(thread.getState());

//        休眠后
        Thread.sleep(3000);
        System.out.println(thread.getState());

//        结束后
        thread.interrupt();
        thread.join();
        System.out.println(thread.getState());
    }
}
